﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" class="popupW100" v-cloak>
        <!-- class="popupW100"为label宽度为100px，共有popupW50、popupW100、popupW150、popupW200可选 -->
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
            size="mini">
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.name" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    <!-- {{user.loginName+mark.m}} -->
                                    角色名称
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.code" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    <!-- {{user.loginName+mark.m}} -->
                                    角色编码
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
               <!--工厂-->
                <input-factorys-all :span="11" v-model="Form.createFactory"></input-factorys-all>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{'备注'+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.remarks"
                                    autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSubmit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}

                </el-form-item>
            </el-row>
        </el-form>
    </div>
    <script type="text/javascript">

        var app = new Vue({
            value1: '',
            el: '#app',
            data: {
                //工厂字典
                factory: [],
                Form: {
                    "code": "",
                    "name": "",
                    "remarks": "",
                    "createFactory": "",
                    "id": guidEmpty,
                },
                //表单验证
                rules: {
                    loginName: [
                        verification.NotNull,
                        { pattern: verification.StringLengthAtoB.t.format(2, 10), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    password: [
                        verification.NotNull

                    ],
                    sex: [
                        verification.NotNullSelect
                    ],
                    name: [
                        verification.NotNull
                    ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/Role/Save', mythis.Form);
                        } else {
                            //验证失败

                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/Role/get?id=' + this.id);
                    this.Form.sex = this.Form.sex + "";
                }
            },
            mounted: function () {
                this.id = getUrlParam("id");
                this.getData();
                //工厂字典
                this.factory = getDicData(['9002'])
            }
        });
    </script>
</body>

</html>